<template>
  <div id="employeeCompensation">
    <div class="pageTitle">
      <p>
        <el-select
          v-model="params.subId"
          placeholder="选择公司"
          @change="selectChange"
          filterable
        >
          <el-option
            v-for="item in setCompanyList"
            :key="item.subid"
            :label="item.abbreviationName"
            :value="item.subid"
          >
          </el-option>
        </el-select>
      </p>
      <div class="row-fu">
        <span>全部职员：{{ numberOf.totalCount }}</span>
        <span>正式员工：{{ numberOf.regularCount }}</span>
        <span>试用期：{{ numberOf.probationCount }}</span>
        <span>兼职：{{ numberOf.parttimeCount }}</span>
      </div>
    </div>
    <div class="pageHead">
      <div class="pageLf">
        <div class="block">
          <el-select
            v-model="params.departmentid"
            placeholder="选择部门"
            clearable
          >
            <el-option
              v-for="item in sDepartment"
              :key="item.departmentid"
              :label="item.departmentName"
              :value="item.departmentid"
            >
            </el-option>
          </el-select>
        </div>
        <div class="block">
          <el-input v-model="params.noORname" placeholder="工号名称"></el-input>
        </div>
        <div class="block">
          <el-button type="primary" @click="onserch" :loading="loading"
            >搜索</el-button
          >
        </div>
        <div class="block">
          <el-popover placement="bottom" :width="400" trigger="click">
            <div class="pagegroup" style="padding: 20px 20px 20px 20px">
              <div class="lfTitle" style="display: flex; line-height: 50px">
                <p style="width: 80px; text-align: right">岗位：</p>
                <el-input
                  v-model="params.postname"
                  type="text"
                  clearable
                ></el-input>
              </div>
              <div class="lfTitle" style="display: flex; line-height: 50px">
                <p style="width: 100px; text-align: right">员工类型：</p>
                <el-select
                  v-model="params.registertype"
                  class="full-width-input"
                  clearable
                >
                  <el-option
                    v-for="item in registerTypeList"
                    :key="item.key"
                    :label="item.value"
                    :value="item.key"
                  ></el-option>
                </el-select>
              </div>
            </div>
            <template #reference>
              <el-button type="text">更多</el-button>
            </template>
          </el-popover>
        </div>
      </div>
      <div class="pageRg">
        <div class="block">
          <el-button type="primary" @click="onimport(1)">定薪导入</el-button>
          <el-button type="primary" @click="onimport(2)">调薪导入</el-button>
          <el-button type="primary" @click="exportGET" :loading="loading1"
            >导出</el-button
          >
        </div>
      </div>
    </div>
    <div class="pageBox">
      <div class="tableContens">
        <el-table
          :data="tableData"
          style="width: 100%"
          height="100%"
          v-loading="loading"
          class="pageInnerTable"
          
        >
          <el-table-column label="姓名" prop="name" align="center"></el-table-column>
          <el-table-column prop="jobno" label="工号" align="center"> </el-table-column>
          <el-table-column prop="departmentName" label="部门" align="center">
          </el-table-column>
          <el-table-column prop="postname" label="岗位" align="center"> </el-table-column>
          <el-table-column label="员工类型" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.registertypeName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="员工状态" align="center">
            <template slot-scope="scope">
              <span>{{
                scope.row.employeestate == 1
                  ? "待入职"
                  : scope.row.employeestate == 2
                  ? "确认入职"
                  : scope.row.employeestate == 3
                  ? "放弃入职"
                  : scope.row.employeestate == 4
                  ? "待转正"
                  : scope.row.employeestate == 5
                  ? "已转正"
                  : scope.row.employeestate == 6
                  ? "待离职"
                  : "已离职"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="wagesTotal" label="工资总额" align="right">
          </el-table-column>
          <el-table-column prop="hiredateThs" label="入职日期" align="center">
          </el-table-column>
          <el-table-column prop="positivedateThs" label="转正日期" align="center">
          </el-table-column>
          <el-table-column prop="leaveDateThs" label="离职日期" align="center">
          </el-table-column>
          <el-table-column label="最新调整时间" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.lastTime">
                {{scope.row.lastTime.includes("0001")?'--':scope.row.lastTime.substr(0, 10)}}
              </span>
              <span v-else>{{
                 ""
              }}</span>
      
            </template>
          </el-table-column>
          <el-table-column prop="" label="备注" align="center"> </el-table-column>
          <el-table-column label="操作" width="180px" align="center">
            <template slot-scope="scope">
              <span
                style="color: #409eff; cursor: pointer"
                @click="getDetail(scope.row)"
                >详情</span
              >
              &nbsp;
              <span
                style="color: #409eff; cursor: pointer"
                @click="onwage(scope.row)"
                v-if="scope.row.salaryType != 2"
                >定薪</span
              >&nbsp;
              <span
                style="color: #409eff; cursor: pointer"
                v-if="!scope.row.isBecome"
              >
                <el-popover
                  placement="left-start"
                  trigger="hover"
                  popper-class="down-popor"
                >
                  <span slot="reference"> 调薪 </span>
                  <p @click="onSalaryincrease(scope.row, 1)">试用期调薪</p>
                  <p @click="onSalaryincrease(scope.row, 2)">转正后调薪</p>
                </el-popover>
              </span>
              <span
                style="color: #409eff; cursor: pointer"
                @click="onSalaryincrease(scope.row, 3)"
                v-else
                >调薪</span
              >
            </template>
          </el-table-column>
        </el-table>
        <pagination
          @getTableData="getList"
          :total="numberOf.totalCount"
          :listQuery="listQuery"
          :pageSizes="pageSizes"
        />
      </div>
    </div>
    <!-- //定薪 -->
    <!-- //批量修改 -->
    <el-dialog
      :title="status == 1 ? '定薪' : status == 2 ? '详情' : '调薪'"
      :visible.sync="isVisible"
      width="960px"
      :before-close="handleClose"
      :close-on-click-modal="false"
    >
      <div class="content-box">
        <div class="title">
          <h3 style="font-weight: 700; color: black; font-size: 18px">
            {{ rowParams.name }}
          </h3>
          <p>
            <span>{{ rowParams.departmentName }}</span
            >&nbsp;<span style="font-size: 16px">|</span>&nbsp;&nbsp;<span>{{
              rowParams.postname ? rowParams.postname : "未设定"
            }}</span>
          </p>
          <p>
            <span>{{ rowParams.registertype == 1 ? "全职" : "兼职" }}</span
            >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>{{
              rowParams.hiredate ? rowParams.hiredate.substr(0, 10) : ""
            }}</span>
          </p>
        </div>
        <!-- 1是定薪 -->
        <div class="container-row" v-if="status == 1">
          <el-form label-position="right" label-width="120px" size="default">
            <div class="static-content-item">
              <div style="font-size: 14px">试用期工资</div>
            </div>
            <el-row>
              <el-col
                :span="8"
                class="grid-cell"
                v-for="(item, index) in wagedata"
                :key="index"
              >
                <el-form-item
                  :label="item.salarycolumnName + '：'"
                  class="label-right-align"
                >
                  <el-input
                    v-model="item.salaryAmount"
                    type="text"
                    clearable
                    :disabled="rowParams.employeestate==5"
                    oninput="value=value.replace(/[^0-9.]/g,'')"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" class="grid-cell">
                <el-form-item label="工资总额：" class="label-right-align">
                  <!-- <el-input v-model="formData.wagedata" type="text" clearable></el-input> -->
                  <span>{{ sumMoneytrial }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-divider></el-divider>
            <div class="static-content-item">
              <div>转正后工资</div>
            </div>
            <el-row>
              <el-col
                :span="8"
                class="grid-cell"
                v-for="(item, index) in probationperiod"
                :key="index"
              >
                <el-form-item
                  :label="item.salarycolumnName + '：'"
                  class="label-right-align"
                >
                  <el-input
                    v-model="item.salaryAmount"
                    type="text"
                    clearable
                    oninput="value=value.replace(/[^0-9.]/g,'')"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" class="grid-cell">
                <el-form-item label="工资总额：" class="label-right-align">
                  <!-- <el-input v-model="formData.probationperiod" type="text" clearable></el-input> -->
                  <span>{{ sumMoneypositive }}</span>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <!-- 2是详情 -->
        <div class="content" v-else-if="status == 2">
          <el-form
            label-position="right"
            label-width="120px"
            size="default"
            v-for="(item, index) in tableDetail"
            :key="index"
          >
            <div class="static-content-item">
              <div style="font-size: 14px">{{ item.typeThs }}</div>
            </div>
            <el-row>
              <el-col
                :span="8"
                class="grid-cell"
                v-for="item1 in item.userSalaryItemDetailViews"
                :key="item1.salarycolumnId"
              >
                <el-form-item
                  :label="item1.salarycolumnName + '：'"
                  class="label-right-align"
                >
                  <el-input
                    v-model="item1.salaryAmount"
                    type="text"
                    clearable
                    disabled
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-divider></el-divider>
          <div class="content-tabel">
            <div style="margin-bottom: 20px">定调薪记录</div>
            <el-table
              :data="tableList"
              style="width: 100%"
              border
              :header-cell-style="{ textAlign: 'center' }"
              :cell-style="{ textAlign: 'center' }"
            >
              <el-table-column prop="name" label="姓名" width="180">
              </el-table-column>
              <el-table-column prop="type" label="定调薪类型" width="180">
                <template slot-scope="scope">
                  <span>{{ scope.row.typeThs }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="startDate" label="生效日期">
                <template slot-scope="scope">
                  <span>{{
                    scope.row.startDate ? scope.row.startDate.substr(0, 10) : ""
                  }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="effectiveThs" label="生效状态">
              </el-table-column>
              <el-table-column
                prop="adjustmentBeforeAmount"
                label="调薪前总金额"
              >
              </el-table-column>
              <el-table-column prop="wagesTotal" label="调薪后总金额">
              </el-table-column>
              <el-table-column prop="adjustmentRatio" label="调薪比例">
              </el-table-column>
              <el-table-column prop="reason" label="调薪原因">
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!-- 3是调薪 -->
        <div class="content" v-else style="margin-top: 10px">
          <el-divider></el-divider>
          <div v-for="idx in userSalaryItemViews" :key="idx.typeThs">
            <span style="font-weight: 600">{{ idx.typeThs }}</span>
            <el-table
              :data="idx.userSalaryItemDetailViews"
              style="width: 100%"
              v-if="detailLoading"
              :header-cell-style="{ textAlign: 'center' }"
              :cell-style="{ textAlign: 'center' }"
            >
              <el-table-column prop="salarycolumnName" label="工资项目">
              </el-table-column>
              <el-table-column prop="salaryAmount" label="调薪前金额">
                <template slot-scope="scope">
                  <div>
                    <span>{{ scope.row.salaryAmount }}</span>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="调薪后金额">
                <template slot-scope="scope">
                  <span v-if="scope.row.salarycolumnName != '工资合计'">
                    <el-input
                      v-model="scope.row.salaryincrease"
                      @blur="onBLSRS(scope.row)"
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      maxLength="9"
                    ></el-input>
                  </span>
                  <span v-else>
                    {{ scope.row.salaryincrease }}
                  </span>
                </template>
              </el-table-column>
              <el-table-column label="调薪比例">
                <template slot-scope="scope">
                  <span>
                    <span>{{ scope.row.proportion + "%" }}</span>
                  </span>
                </template>
              </el-table-column>
            </el-table>
            <el-divider></el-divider>
          </div>
          <el-table
            :data="[{}]"
            style="width: 100%"
            v-if="!detailLoading"
            v-loading="true"
            :header-cell-style="{ textAlign: 'center' }"
            :cell-style="{ textAlign: 'center' }"
          >
            <el-table-column prop="salarycolumnName" label="工资项目">
            </el-table-column>
            <el-table-column prop="salaryAmount" label="调薪前金额">
            </el-table-column>
            <el-table-column label="调薪后金额"> </el-table-column>
            <el-table-column label="调薪比例"> </el-table-column>
          </el-table>
          <div style="padding: 20px 20px 20px 20px">
            <el-form
              :model="formData"
              label-position="right"
              label-width="80px"
              size="default"
              @submit.native.prevent
            >
              <el-row>
                <el-col :span="8" class="grid-cell">
                  <el-form-item label="生效日期">
                    <el-date-picker
                      v-model="formData.startDate"
                      type="date"
                      placeholder="选择时间"
                      :picker-options="optionspicker"
                      value-format="yyyy-MM-dd"
                    >
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="16" class="grid-cell">
                  <el-form-item label="调薪原因">
                    <el-input
                      v-model="formData.reason"
                      type="textarea"
                      clearable
                      maxlength="50"
                      show-word-limit
                      placeholder="说点什么来"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isVisible = false">取 消</el-button>
        <el-button type="primary" @click="onstatusSave">确认</el-button>
      </span>
    </el-dialog>
    <getimport
      :isDiaor="isDiaor"
      @handleClose="closeLIVE"
      :typestatus="isDiaorType"
      :subId="params.subId"
    />
  </div>
</template>
<script>
import pagination from "@/components/pagination.vue";
import { getDepartmentView, getCompanyList } from "@/util/xc/utils";
import { mapState } from "vuex";
import requestList from "@/api/moduleApi_xc/management";
import getimport from "../annualBonusReport/components/getimport.vue";
export default {
  name: "employeeCompensation", //员工薪酬
  components: {
    pagination,
    getimport,
  },
  inject: ["reload"],
  data() {
    return {
      optionspicker: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        },
      }, //时间限制
      tableData: [],
      isDiaor: false,
      isDiaorType: 2,
      typeths: 1,
      proportionflag: false,
      loading1: false,
      pageSizes: [50, 100, 200, 500],
      sDepartment: [], //部门
      listQuery: {},
      rowParams: {
        userId: "",
        name: "",
        postname: "",
        departmentName: "",
        hiredate: "",
        registertype: 1,
      },
      loading: false,
      isVisible: false,
      detailLoading: false,
      userSalaryItemViews: [
        {
          userSalaryItemDetailViews: [{}],
        },
      ],
      tableDetail: [], //定调薪记录
      tableList: [],
      status: 1,
      wagedata: [], //试用期
      probationperiod: [], //转正
      formData: {
        rejectReason: "",
        reason: "",
        startDate: "",
      },
      params: {
        subId: "",
        noORname: "",
        departmentid: "",
        postname: "",
        registertype: "", //员工类型，目前(全职：1，兼职：2)
        salaryType: 0, //1：未定薪 2：已定薪 3：已调薪
        PageIndex: 1,
        PageSize: 50,
      },
      registerTypeList: [],
      setCompanyList: [],
      numberOf: {
        totalCount: 0, //全部人员
        regularCount: 0, //正式员工
        probationCount: 0, //试用期员工
        parttimeCount: 0, //兼职
      },
    };
  },
  computed: {
    ...mapState({
      setUserList: (state) => state.reward.userList,
    }),
    // 试用期工资总计
    sumMoneytrial() {
      let sum = 0;
      this.wagedata.forEach((item) => {
        if (item.salarycolumnName != "工资合计") {
          sum += Number(item.salaryAmount ? item.salaryAmount : 0);
        }
      });
      return sum;
    },
    // 转正后工资总计
    sumMoneypositive() {
      let sum = 0;
      this.probationperiod.forEach((item) => {
        if (item.salarycolumnName != "工资合计") {
          sum += Number(item.salaryAmount);
        }
      });
      return sum;
    },
  },
  async mounted() {
    await this.getinitSI();
    this.onparamsList();
    this.getstatus();
  },
  methods: {
    async getinitSI() {
      const { data } = await this.$api.commonXc
        .initSubCompanyList()
        .then((res) => res.data);
      this.setCompanyList = data;
      this.params.subId =
       this.setCompanyList.length > 0 ? this.setCompanyList[0].subid : "";
      this.getCompany();
    },
    getstatus() {
      this.$api.commonXc.GetRegistertype().then((res) => {
        console.log("员工类型列表", res);
        if (res.status == 200) {
          this.registerTypeList = res.data.data;
        }
      });
    },
    // 导入
    onimport(e) {
      this.isDiaorType = e == 1 ? 2 : 3;
      this.isDiaor = true;
    },
    closeLIVE(status) {
      this.isDiaor = false;
      if (status == "成功") {
        this.onparamsList();
      }
    },
    // 初始化部门
    async getCompany() {
      this.sDepartment = [];
      this.params.departmentid = "";
      if (this.params.subId) {
        let { data } = await getDepartmentView(this.params.subId);
        this.sDepartment = data;
      }
    },
    // 选择公司
    selectChange() {
      this.getCompany();
      this.onparamsList();
    },
    //薪酬列表
    async onparamsList() {
      this.loading = true;
      let paramsLint = { ...this.params };
      Object.keys(paramsLint).forEach((item) => {
        if (paramsLint[item] == "") {
          delete paramsLint[item];
        }
      });
      try {
        let { data } = await requestList
          .Getaddxinchou(paramsLint)
          .then((res) => res.data);
        let {
          totalCount,
          regularCount,
          probationCount,
          parttimeCount,
          userSalaryViews,
        } = data;
        this.tableData = userSalaryViews;
        this.numberOf.totalCount = totalCount;
        this.numberOf.regularCount = regularCount;
        this.numberOf.probationCount = probationCount;
        this.numberOf.parttimeCount = parttimeCount;
        this.loading = false;
      } catch (err) {
        setTimeout(() => {
          this.loading = false;
        }, 3000);
      }
    },
    //搜索
    onserch() {
      this.onparamsList();
    },
    //关闭弹窗
    handleClose() {
      this.isVisible = false;
    },
    //分页搜索
    getList(e, status) {
      if (status == "size") {
        this.params.PageSize = e;
      } else {
        this.params.PageIndex = e;
      }
      this.onparamsList();
    },
    //*删除操作
    ondelList() {
      this.$confirm("此操作将永久删除该条数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //导出
    exportGET() {
      this.loading1 = true;
      let paramsLint = { ...this.params };

      Object.keys(paramsLint).forEach((item) => {
        if (paramsLint[item] == "") {
          delete paramsLint[item];
        }
      });
      requestList.expostxinchouHistory(paramsLint).then((res) => {
        let { data, status } = res.data;
        if (status == 200) {
          window.open(data);
          this.loading1 = false;
        } else {
          setTimeout(() => {
            this.loading1 = false;
          }, 3000);
        }
      });
    },
    // 调薪失去焦点
    onBLSRS(row) {
      let { salaryincrease, salaryAmount, proportion } = row;
      if (Number(salaryAmount) == 0) {
        row.proportion = 0;
      } else {
        proportion =
          (Number(salaryincrease) - Number(salaryAmount)) /
            Number(salaryAmount) *
          100;
        row.proportion = proportion.toFixed(2);
      }
      this.userSalaryItemViews.map((item) => {
        let sum = 0;
        item.userSalaryItemDetailViews.forEach((idx) => {
          if (idx.salarycolumnName == "工资合计") {
            idx.salaryincrease = sum;
            if (Number(idx.salaryAmount) == 0) {
              idx.proportion = 0;
            } else {
              idx.proportion =
                (Number(idx.salaryincrease) - Number(idx.salaryAmount)) /
                  Number(idx.salaryAmount) *
                100;
              idx.proportion = idx.proportion.toFixed(2);
            }
          } else {
            if (idx.salaryincrease != "") {
              sum += idx.salaryincrease = Number(idx.salaryincrease);
            }
          }
        });
      });
      row.status = true;
    },
    //定薪 调薪 详情 保存页
    onstatusSave() {
      if (this.status == 2) {
        this.handleClose();
        return;
      }
      let params = [];
      if (this.status == 1) {
        //定薪保存
        params = [
          {
            type: 1,
            currentType: 1,
            userId: this.rowParams.userId,
            subId: this.params.subId,
            salaryRecordDtos: [...this.wagedata],
          },
          {
            type: 2,
            currentType: 2,
            userId: this.rowParams.userId,
            subId: this.params.subId,
            salaryRecordDtos: [...this.probationperiod],
          },
        ];
        if(this.rowParams.employeestate == 5) {
          params = params.splice(1, 1);
        }
        params.map((idx) => {
          idx.salaryRecordDtos.forEach((item) => {
            item.salaryAmount = Number(item.salaryAmount);
          });
        });
        requestList.Getwageincreaserecord(params).then((res) => {
          let { status } = res.data;
          if (status == 200) {
            this.$message({
              type: "success",
              message: "保存成功!",
            });
            this.reload();
          }
        });
      } else if (this.status == 3) {
        //调薪保存
        if (this.formData.startDate == "") {
          this.$message({
            type: "warning",
            message: "请选择生效时间",
          });
          return;
        }
        if (this.formData.reason == "") {
          this.$message({
            type: "warning",
            message: "请输入调薪原因",
          });
          return;
        }
        params = JSON.parse(JSON.stringify([...this.userSalaryItemViews]));

        params.map((idx, index) => {
          idx.type = 3;
          idx.currentType = this.typeths;
          idx.userId = this.rowParams.userId;
          idx.subId = this.params.subId,
          idx.startDate = this.formData.startDate,
          idx.reason = this.formData.reason;
          idx.salaryRecordDtos = [];
          try {
            idx.userSalaryItemDetailViews.map((idx1) => {
              let obj = {};
              if (idx1.salarycolumnName != "工资合计") {
                if (idx1.status == false) {
                  throw new Error("End");
                }
                obj.salaryAmount = Number(idx1.salaryincrease);
                obj.salaryitemId = idx1.salaryitemId;
                obj.salarycolumnName = idx1.salarycolumnName;
                obj.salaryitemName = idx1.salaryitemName;
                obj.salarycolumnId = idx1.salarycolumnId;
                idx.salaryRecordDtos.push(obj);
              }
            });
          } catch (e) {
            this.$message({
              type: "warning",
              message: idx.typeThs + "调薪项不能为空",
            });
            this.proportionflag = true;
          }
          delete idx.wagesTotal;
          delete idx.typeThs;
          delete idx.userSalaryItemDetailViews;
        });
        if (!this.proportionflag) {
          requestList.Getwageincreaserecord(params).then((res) => {
            let { status } = res.data;
            if (status == 200) {
              this.$message({
                type: "success",
                message: "保存成功!",
              });
              this.reload();
            }
          });
        }
      }
    },
    //*详情
    getDetail(row) {
      this.isVisible = true;
      this.status = 2;
      this.rowParams = row;
      let { salaryId } = row;
      requestList.GetxinchouDetail({ salaryId }).then((res) => {
        let { data, status } = res.data;
        if (status == 200) {
          console.log(data, "data");
          let { salaryRecordViews, userSalaryItemViews } = data;
          this.tableDetail = this.inheritAttrsData(userSalaryItemViews);
          this.tableList = salaryRecordViews;
        }
      });
    },
    //*定薪
    onwage(row) {
      this.status = 1;
      this.isVisible = true;
      this.rowParams = row;
      this.getmoneysan();
    },
    //*调薪
    onSalaryincrease(row, type) {
      this.status = 3;
      this.typeths = type;
      this.isVisible = true;
      this.rowParams = row;
      this.userSalaryItemViews = [];
      this.formData.reason = "";
      this.formData.startDate = "";
      requestList
        .Getclickincreaserecord({ userId: this.rowParams.userId, type })
        .then((res) => {
          let { data, status } = res.data;
          if (status == 200) {
            let userSalaryItemViews = data.userSalaryItemViews;
            this.userSalaryItemViews =
              this.inheritAttrsData(userSalaryItemViews);
            this.detailLoading = true;
          }
        });
    },
    inheritAttrsData(data) {
      let userSalaryItemViews = data;
      userSalaryItemViews.map((item) => {
        item.userSalaryItemDetailViews.push({
          salaryAmount: "",
          salarycolumnId: 888888888888888,
          salarycolumnName: "工资合计",
        });
        let sum = 0;
        item.userSalaryItemDetailViews.forEach((idx) => {
          idx.salaryincrease = "";
          idx.proportion = 0;

          if (idx.salarycolumnName == "工资合计") {
            idx.salaryAmount = sum;
            idx.status = true;
          } else {
            idx.status = false;
            sum += idx.salaryAmount = Number(idx.salaryAmount);
          }
        });
      });
      return userSalaryItemViews;
    },
    //获取工资小项
    getmoneysan() {
      requestList.GetBasicsalary().then((res) => {
        let { status, data } = res.data;
        if (status == 200) {
          this.wagedata = data;
          this.wagedata.forEach((item) => {
            this.$set(item, "salaryAmount", "");
          });
          this.probationperiod = JSON.parse(JSON.stringify(this.wagedata));
        }
      });
    },
  },
};
</script>
<style lang="less">
.down-popor {
  width: 100px !important;
  min-width: 100px !important;
  p {
    text-align: center;
    line-height: 30px;
    cursor: pointer;
    font-size: 12px;
  }
}
</style>
<style lang="less" scoped>
#employeeCompensation {
  .pageTitle {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    background-color: #ffffff;
    border: none;
    border-bottom: 1px solid #ebebeb;

    p {
      min-width: 240px;
      line-height: 30px;
    }
    .row-fu {
      font-size: 12px;
      line-height: 30px;
      color: #666666;
      span {
        margin-left: 00.5vw;
      }
    }
  }
  .pageHead {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    height: auto;
    margin-top: 10px;

    .pageLf,
    .pageRg {
      display: flex;
      .block {
        margin-right: 1vw;
        display: flex;
      }
    }
  }
  .title {
    p,
    h3 {
      text-align: center;
      margin-top: 0.8vh;
    }
  }
  .container-row {
    padding: 20px 20px 20px 20px;
    .el-form-item {
      margin-bottom: 10px;
      font-size: 12px;
    }
  }
  .content-tabel {
    margin-bottom: 20px;
  }
  .pageBox {
    margin-top: 17px;
    width: 100%;
    height: calc(100% - 120px);
    float: left;
    position: relative;
    overflow: auto;
    .tableContens {
      height: calc(100% - 36px);
      position: relative;
      width: 100%;
      padding-right: 0;
    }
  }
}
</style>